<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 下列代码有什么错误？  有2出大错误哦
    // const username = document.querySelector('.username').value
    // const password = document.querySelector('.password').value
    // document.querySelector('button').addEventListener('click', function () {
    //   const obj = {
    //     username,
    //     password,
    //     sayHi = () {
    //       console.log('hi~')
    //     }
    //   }
    //   console.log(obj)
    // })

    const username = document.querySelector('.username').value
    const password = document.querySelector('.password').value
    document.querySelector('button').addEventListener('click', function () {
      const obj = {
        username,
        password,
        sayHi :() => {
          console.log('hi~')
        }
      }
      console.log(obj)
    })
  </script>
</body>

</html>